﻿using RuoVea.ExDto;
using RuoVea.ExEnum;
using SqlSugar;

namespace RuoVea.Universal.Server.Models;

/// <summary>
/// 元数据表
/// </summary>
public class TableMetadata : IAuditableEntity
{
    /// <summary>
    /// 主键
    /// </summary>
    [SugarColumn(IsPrimaryKey = true, IsIdentity = false, IsNullable = false)]
    public long Id { get; set; }

    /// <summary>
    /// 获取或设置主键类别，主要用于区分每个上传的配置信息的类别。
    /// </summary>
    [SugarColumn(IsNullable = false)]
    public string PrimaryKeyType { get; set; }

    /// <summary>
    /// 获取或设置表名。
    /// </summary>
    [SugarColumn(IsNullable = false)]
    public string TableName { get; set; }

    /// <summary>
    /// 获取或设置重复数据的处理方式：Insert（插入）、Update（更新）、Discard（丢弃）。
    /// 默认为'Insert'。
    /// </summary>
    [SugarColumn(IsNullable = false)]
    public string TransferType { get; set; }

    /// <summary>
    /// 获取或设置从表名称列表（逗号分隔），用于一主多从表结构。
    /// 如果为"MasterData"表示是主表，否则存储从表名称如"OrderDetails,OrderItems"
    /// </summary>
    [SugarColumn(IsNullable = true)]
    public string SubTableNames { get; set; }

    /// <summary>
    /// 获取或设置关联字段名称（用于主从表关联）
    /// </summary>
    [SugarColumn(IsNullable = true)]
    public string RelationField { get; set; }

    /// <summary>
    /// 
    /// </summary>
    [SugarColumn(IsNullable = false)]
    public DateTime? CreateTime { get; set; }
    /// <summary>
    /// 
    /// </summary>
    [SugarColumn(IsNullable = true)]
    public long? Creator { get; set; }
    /// <summary>
    /// 
    /// </summary>
    [SugarColumn(IsNullable = false)]
    public DateTime? ModifyTime { get; set; }
    /// <summary>
    /// 
    /// </summary>
    [SugarColumn(IsNullable = true)]
    public long? Modifier { get; set; }
    /// <summary>
    /// 
    /// </summary>
    [SugarColumn(IsNullable = false)]
    public IsDelete? Deleted { get; set; } = IsDelete.N;
}
